package com.hwua.tonyshop.controller.fg;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hwua.tonyshop.criteria.GoodsInfoCriteria;
import com.hwua.tonyshop.entity.mojo.GoodsInfoAO;
import com.hwua.tonyshop.service.IGoodsInfoService;
import com.slkj.autocode.entity.ServiceResult;

@Controller
@RequestMapping(value = "/fore/goods")
public class GoodsDetialController {
	@Resource
	IGoodsInfoService goodsInfoService;
	/**
	 * 跳转到商品详情页
	 * @param model
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/toGoodsDetailPage", method = { RequestMethod.GET, RequestMethod.POST })
	public String toGoodsDetailPage(String token,Integer goodsId,Model model,HttpServletRequest request,HttpServletResponse response) {
		model.addAttribute("token",token);
		model.addAttribute("goodsId",goodsId);
		return "foreground/public/goods_details";
	}
	/**
	 * 通过商品id获取商品信息
	 * @param goodsId
	 * @param model
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/getGoodsInfo", method = { RequestMethod.GET, RequestMethod.POST })
	@ResponseBody
	public ServiceResult<GoodsInfoAO> getGoodsInfo(Integer goodsId,Model model,HttpServletRequest request,HttpServletResponse response) {
		return goodsInfoService.selectById(goodsId);
	}
	
}
